package com.maiji.cloud.service;

import com.maiji.cloud.entities.community.ComActivity;
import com.maiji.cloud.entities.community.ComMsgInfo;
import com.maiji.cloud.repository.ComActRepository;
import com.maiji.cloud.repository.ComMsgInfoRepository;
import com.maiji.cloud.request.BaseInputDto;
import com.maiji.cloud.request.community.ComUserMessageInputDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.beans.Transient;
import java.util.ArrayList;
import java.util.List;

@Service
@Transactional
public class AsyncService {

    @Autowired
    ComMsgInfoRepository msgInfoRepository;

    @Autowired
    ComActRepository actRepository;

    @Autowired
    ComUserMessageService userMessageService;

    @Async
    public void asycSaveMsgInfo(ComMsgInfo msgInfo){
        msgInfoRepository.save(msgInfo);
    }

    @Async
    public void asycSaveActs(List<ComActivity>activities){
        actRepository.save(activities);
    }

    @Async
    public void asycCreateMessage(ComUserMessageInputDto inputDto){
        userMessageService.createMessages(inputDto);
    }

    @Async
    public void asycCreateMessageList(List<ComUserMessageInputDto > inputDtoList){
        userMessageService.createMessagesList(inputDtoList);
    }

}
